package scantask.containers.operationStanzas;

import java.util.Vector;

import scantask.server.domainLayer.ControllerInterface;
import scantask.server.domainLayer.Exceptions.GetInformativeDataException;

import scantask.containers.InformationObject;
import scantask.containers.WeekDate;

public class GetInformativeDataStanza extends Stanza {
	
	private String _userName;
	private WeekDate _date;
	
	public GetInformativeDataStanza(String userName, WeekDate date) {
		this._userName = userName;
		this._date = date;
	}

	@Override
	public String perform(ControllerInterface controller) {
		Vector<InformationObject> ans;
		try {
			ans = controller.getInformativeData(this._userName, this._date);
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Sending informative date to " + this._userName);
			return this.parseToXML(ans);
		} catch (GetInformativeDataException e) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Sending exception to " + this._userName + " about get informative data request");
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning(e.getErrorDescription());
			return this.parseToXML(e);
		}
		/* JUNK TEST
		Vector<InformationObject> ans = new Vector<InformationObject>();
		try {
			ans.add(new SyntheticObject(new Coordinate(1,1), new ZoomLevel(2,2), "suka", 3));
			ans.add(new Temperature(new Coordinate(3,3), null, 4.5, new WeekDate(20, 2000), false));
			ans.add(new Crop(new Coordinate(5,5), null, 6.5, new WeekDate(20, 2000), true, "blabla"));
		} catch (UnInitializeObjectException e) {
			e.printStackTrace();
		} catch (IllegaleRadiusException e) {
			e.printStackTrace();
		} catch (InvalidSyntheticObjectTypeException e) {
			e.printStackTrace();
		} catch (InvalidCoordinateValueException e) {
			e.printStackTrace();
		} catch (InvalidZoomLevelParametersException e) {
			e.printStackTrace();
		} catch (InvalidWeekNumberException e) {
			e.printStackTrace();
		} catch (InvalidYearException e) {
			e.printStackTrace();
		} catch (InvalidMeasurementTypeException e) {
			e.printStackTrace();
		} */

	}

}
